<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('品种预警')"/>
</head>
<body>
<form action="" class="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">id</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="id" placeholder="请输入标题" th:value="${stockWarn.id}" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red;">*</span>预警产品</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="proId" placeholder="请输入标题"
                               th:value="${stockWarn.proId}" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red;">*</span>产品名称</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="proName" placeholder="请输入标题"
                               th:value="${stockWarn.proName}" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">预警描述</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" name="warnDesc"
                                  th:text="${stockWarn.warnDesc}" placeholder="请输入描述"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">二次预警价格</label>
                    <div class="layui-input-block">
                        <input class="layui-input"
                               name="warnPrice" placeholder="请输入标题" th:value="${stockWarn.warnPrice}" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">审核状态</label>
                    <div class="layui-input-block">
                        <input name="auditStatus" th:checked="${stockWarn.auditStatus eq '0'}" title="未审核" type="radio" value="0">
                        <input checked name="auditStatus" th:checked="${stockWarn.auditStatus eq '1'}" title="审核通过" type="radio" value="1">
                        <input checked name="auditStatus" th:checked="${stockWarn.auditStatus eq '2'}" title="审核未通过" type="radio" value="2">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">重点预警</label>
                    <div class="layui-input-block">
                        <input name="keyWarn" th:checked="${stockWarn.keyWarn eq '0'}" title="不参与" type="radio" value="0">
                        <input checked name="keyWarn" th:checked="${stockWarn.keyWarn eq '1'}" title="参与" type="radio" value="1">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red;">*</span>处理结果</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" name="handlResult"
                                  th:text="${stockWarn.handlResult}" placeholder="请输入价格"></textarea>

                    </div>
                </div>

            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button class="pear-btn pear-btn-primary pear-btn-sm" lay-filter="role-update" lay-submit=""
                    type="submit">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button class="pear-btn pear-btn-sm" type="reset">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;

        form.on('submit(role-update)', function (data) {
            $.ajax({
                url: '/stock/warn/update',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'put',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("futures-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>